module.exports = {
    getBody(roomname) {
        let extensionnum = Game.rooms[roomname].find(FIND_STRUCTURES, {
            filter: structure => structure.structureType == STRUCTURE_EXTENSION
        }).length;
        let body = [];
        let maxnum = 8;
        let bodynum = parseInt((extensionnum + 6) / 4);
        bodynum = bodynum <= maxnum ? bodynum : maxnum;
        for (let i = 0; i < bodynum; i++) {
            body = [...body, MOVE, WORK, CARRY];
        }
        return body;
    },
    getAttackerBody(roomname) {
        let extensionnum = Game.rooms[roomname].find(FIND_STRUCTURES, {
            filter: structure => structure.structureType == STRUCTURE_EXTENSION
        }).length;
        let body = [];
        let maxnum = 5;
        let bodynum = parseInt((extensionnum + 6) / 5);
        bodynum = bodynum <= maxnum ? bodynum : maxnum;
        for (let i = 0; i < bodynum; i++) {
            body = [...body, TOUGH, TOUGH];
        }
        for (let i = 0; i < bodynum; i++) {
            body = [...body, MOVE, MOVE, MOVE];
        }
        for (let i = 0; i < bodynum; i++) {
            body = [...body, ATTACK];
        }
        return body;
    },
    getHealerBody(roomname) {
        let extensionnum = Game.rooms[roomname].find(FIND_STRUCTURES, {
            filter: structure => structure.structureType == STRUCTURE_EXTENSION
        }).length;
        let body = [];
        let maxnum = 3;
        let bodynum = parseInt((extensionnum + 6) / 6);
        bodynum = bodynum <= maxnum ? bodynum : maxnum;
        for (let i = 0; i < bodynum; i++) {
            body = [...body, MOVE];
        }
        for (let i = 0; i < bodynum; i++) {
            body = [...body, HEAL];
        }
        return body;
    },
    getCarrierBody(roomname) {
        let extensionnum = Game.rooms[roomname].find(FIND_STRUCTURES, {
            filter: structure => structure.structureType == STRUCTURE_EXTENSION
        }).length;
        let body = [];
        let maxnum = 5;
        let bodynum = parseInt((extensionnum + 6) / 4);
        bodynum = bodynum <= maxnum ? bodynum : maxnum;
        for (let i = 0; i < bodynum; i++) {
            body = [...body, MOVE, MOVE, CARRY, CARRY];
        }
        return body;
    }
}